package com.epam.DAO.JPA;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;

import com.epam.DAO.CarDAO;
import com.epam.entity.Car;

public class CarDAOJPA extends GenericDAOJPA<Car> implements CarDAO {

	public CarDAOJPA() {
		super(Car.class);
	}

	@Override
	public List<Car> getAvaliableCars() {
		EntityManager em = getEntityManager();
		TypedQuery<Car> query = em.createQuery(
				"SELECT c FROM Car c WHERE c.isAvaliable = true", Car.class);
		List<Car> list = query.getResultList();
		em.close();
		return list;
	}

}